<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="file" name="file" id="file">

    <script>
        document.getElementById('file').onchange = function (e) {
            var file = e.target.files[0];
            var reader = new FileReader();//new一个FileReader实例
            // reader.readAsDataURL(file);//发起异步请求
            reader.onload = function () {
                console.log(this.result);
            }
            reader.readAsText(file);
        }
    </script>
</body>

</html>